import 'package:flutter/material.dart';
import '../model/goods_detail.dart';
import '../config/service_method.dart';
import 'dart:convert';

class GoodsDetailProvide with ChangeNotifier {
  GoodsDetail goodsDetail = null;
  bool isLeft = true;
  bool isRight = false;

  changeLeftOrRight(String changeState) {
    if (changeState == 'left') {
      isLeft = true;
      isRight = false;
    } else {
      isLeft = false;
      isRight = true;
    }
    notifyListeners();
  }

  getGoodsInfo(String id) async {
    var formData = {'goodId': id};
    await postRequest('getGoodDetailById', data: formData).then((onValue) {
      var responseData = json.decode(onValue.toString());
      goodsDetail = GoodsDetail.fromJson(responseData);
      notifyListeners();
    });
  }
}
